package com.cskaoyan.connectionpool;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * 创建日期: 2022/03/24 10:08
 *
 * @author ciggar
 */
public class C3p0Utils {

    static DataSource dataSource;

    static {

        dataSource = new ComboPooledDataSource();

    }


    // 获取连接
    public static Connection getConnection(){

        Connection connection = null;
        try {
            connection = dataSource.getConnection();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return connection;

    }
}
